/**
 * 
 */
package com.teach.servlet.admin;

import java.io.IOException;
import java.util.List;

import javax.management.RuntimeErrorException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.teach.entity.User;
import com.teach.service.UserDisplayService;
import com.teach.service.UserListService;
import com.teach.service.impl.UserDisplayServiceImpl;
import com.teach.service.impl.UserListServiceImpl;

/**
 * @author Liulianqiu
 *2020年7月28日
 */
@WebServlet("/admin/list1.let")
public class UserListServlet extends HttpServlet{
	
	private UserListService userService = new UserListServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int rowMax = 5;
		try {
			rowMax = Integer.valueOf(request.getParameter("rowMax"));
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		
		int current = 1;
		try {
			current = Integer.valueOf(request.getParameter("current"));
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		int total = userService.total();
		request.setAttribute("total", total);
		List<User> list1 = userService.list1(current,rowMax);
		request.setAttribute("list1", list1);
//		System.out.println(request.getContextPath());
		request.getRequestDispatcher("/admin/list1.jsp").forward(request, response);
	}

}
